package com.lc.luzhengtang.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lc.luzhengtang.BaseApplication;
import com.lc.luzhengtang.R;
import com.lc.luzhengtang.base.BaseActivity;
import com.lc.luzhengtang.bean.ProFitBean;
import com.lc.luzhengtang.conn.ConnProfit;
import com.zcx.helper.http.AsyCallBack;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/5/5.
 */
public class ProfitActivity extends BaseActivity {


    ImageView imgNews;
    @BindView(R.id.text_money_all)
    TextView textMoneyAll;
    @BindView(R.id.text_role1)
    TextView textRole1;
    @BindView(R.id.normal_vip)
    TextView normalVip;
    @BindView(R.id.text_money)
    TextView textMoney;
    @BindView(R.id.text_role2)
    TextView textRole2;
    @BindView(R.id.text_role)
    TextView textRole;
    @BindView(R.id.text_shouyi)
    TextView textShouyi;
    @BindView(R.id.text_role3)
    TextView textRole3;
    @BindView(R.id.text_midele_person)
    TextView textMidelePerson;
    @BindView(R.id.text_leiji_money)
    TextView textLeijiMoney;
    @BindView(R.id.text_role4)
    TextView textRole4;
    @BindView(R.id.text_chuji_person)
    TextView textChujiPerson;
    @BindView(R.id.text_leiji_money_gaoji)
    TextView textLeijiMoneyGaoji;
    @BindView(R.id.layout_putong)
    LinearLayout layoutPutong;
    @BindView(R.id.layout_chuji)
    LinearLayout layoutChuji;
    @BindView(R.id.layout_middle)
    LinearLayout layoutMiddle;
    @BindView(R.id.layout_gaoji)
    LinearLayout layoutGaoji;
    @BindView(R.id.text_normal_person)
    TextView textNormalPerson;


    private String putong_id, chuji_id, middle_id, gaoji_id;

    String textRole_submit;
    String textRole_submit2;
    String textRole_submit3;
    String textRole_submit4;

    String text_putongid, getTextRole_submit0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_profit);
        ButterKnife.bind(this);
        imgNews = (ImageView) findViewById(R.id.img_news);
        imgNews.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        getProfitData();
    }


    public void getProfitData() {
        new ConnProfit(BaseApplication.basePreferences.readUid(), new AsyCallBack<ProFitBean>() {
            @Override
            public void onStart(int type) throws Exception {
                super.onStart(type);
                showLoading();
            }

            @Override
            public void onSuccess(String toast, int type, Object o, ProFitBean s) throws Exception {
                //总价钱
                textMoneyAll.setText(s.getCommission() + "");
                //普通会员
//           putong_id     , chuji_id, middle_id, gaoji_id
                putong_id = s.getData().getSpecial().getRole_id() + "";
                textRole1.setText(s.getData().getSpecial().getRole());
                normalVip.setText(s.getData().getSpecial().getTydlren() + "" + "人");
                textMoney.setText("￥" + s.getData().getSpecial().getTydlmoney() + "");
                textRole_submit = s.getData().getSpecial().getRole();
                //初级零售商

                chuji_id = s.getData().getDistrict().getRole_id() + "";
                textRole2.setText(s.getData().getDistrict().getRole());
                textRole.setText(s.getData().getDistrict().getTydlren() + "" + "人");
                textRole_submit2 = s.getData().getDistrict().getRole();

                textShouyi.setText("￥" + s.getData().getDistrict().getTydlmoney() + "");
                //中级零售商
                middle_id = s.getData().getOfficials().getRole_id() + "";
                textRole3.setText(s.getData().getOfficials().getRole());
                textMidelePerson.setText(s.getData().getOfficials().getTydlren() + "" + "人");
                textLeijiMoney.setText("￥" + s.getData().getOfficials().getTydlmoney() + "");
                textRole_submit3 = s.getData().getOfficials().getRole();
                //高级零售商
                gaoji_id = s.getData().getPartner().getRole_id() + "";
                textRole4.setText(s.getData().getPartner().getRole());
                textChujiPerson.setText(s.getData().getPartner().getTydlren() + "");
                textLeijiMoneyGaoji.setText("￥" + s.getData().getPartner().getTydlmoney() + "");
                textRole_submit4 = s.getData().getOfficials().getRole();

//                String text_putongid,getTextRole_submit0;
                textNormalPerson.setText("普通用户(" + s.getData().getOrdinary().getTydlren() + "人" + ")");
                text_putongid = s.getData().getOrdinary().getRole_id() + "";
                getTextRole_submit0 = s.getData().getOrdinary().getTydlren() + "";


            }

            @Override
            public void onEnd(String toast, int type) throws Exception {
                super.onEnd(toast, type);
                dismissLoading();
            }

            @Override
            public void onEnd(String toast, int type, Object o) throws Exception {
                super.onEnd(toast, type, o);
                dismissLoading();
            }
        }


        ).execute(ProfitActivity.this, false);
    }


    @OnClick({R.id.img_news, R.id.text_money_all, R.id.text_role1, R.id.normal_vip, R.id.text_money, R.id.text_role2, R.id.text_role, R.id.text_shouyi, R.id.text_role3, R.id.text_midele_person, R.id.text_leiji_money, R.id.text_role4, R.id.text_chuji_person, R.id.text_leiji_money_gaoji, R.id.layout_putong, R.id.layout_chuji, R.id.layout_middle, R.id.layout_gaoji, R.id.text_normal_person})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.img_news:
                finish();
                break;
            case R.id.text_money_all:
                break;
            case R.id.text_role1:
                break;
            case R.id.normal_vip:
                break;
            case R.id.text_money:
                break;
            case R.id.text_role2:
                break;
            case R.id.text_role:
                break;
            case R.id.text_shouyi:
                break;
            case R.id.text_role3:
                break;
            case R.id.text_midele_person:
                break;
            case R.id.text_leiji_money:
                break;
            case R.id.text_role4:
                break;
            case R.id.text_chuji_person:
                break;
            case R.id.text_leiji_money_gaoji:
                break;

//普通会员
            case R.id.layout_putong:
                Intent intent = new Intent();
                intent.putExtra("role_id", putong_id);
                intent.putExtra("role_name", textRole_submit);

                intent.setClass(ProfitActivity.this, TeamActivityCommonListActivity.class);
                startActivity(intent);

                break;
            //初级会员

            case R.id.layout_chuji:
                Intent intent2 = new Intent();
                intent2.putExtra("role_id", chuji_id);
                intent2.putExtra("textRole_submit2", textRole_submit2);
                intent2.putExtra("myflag", "2");
                intent2.setClass(ProfitActivity.this, TeamActivityListActivity.class);
                startActivity(intent2);
                break;
            //中级会员
            case R.id.layout_middle:
                Intent intent3 = new Intent();
                intent3.putExtra("role_id", middle_id);
                intent3.putExtra("myflag", "3");
                intent3.putExtra("textRole_submit3", textRole_submit3);
                intent3.setClass(ProfitActivity.this, TeamActivityListActivity.class);
                startActivity(intent3);
                break;
            //高级会员
            case R.id.layout_gaoji:
                Intent intent4 = new Intent();
                intent4.putExtra("role_id", gaoji_id);
                intent4.putExtra("myflag", "4");
                intent4.putExtra("textRole_submit4", textRole_submit4);
                intent4.setClass(ProfitActivity.this, TeamActivityListActivity.class);
                startActivity(intent4);
                break;

            case R.id.text_normal_person:
             /*   textNormalPerson.setText("普通用户(" + s.getData().getOrdinary().getTydlren() + "人" + ")");
                text_putongid=s.getData().getOrdinary().getRole_id()+"";
                getTextRole_submit0=s.getData().getOrdinary().getTydlren()+"";*/
                Intent intent5 = new Intent();
                intent5.putExtra("role_id", text_putongid);
                intent5.putExtra("myflag", "0");
                intent5.putExtra("textRole_submit4", getTextRole_submit0);
                intent5.setClass(ProfitActivity.this, TeamActivityListActivity2.class);
                startActivity(intent5);
                break;


        }
    }

}
